# use pkg-config for getting CFLAGS and LDFLAGS
FFMPEG_LIBS = libavdevice libavformat libavcodec
EXIST = $(shell pkg-config --exists $(FFMPEG_LIBS); echo $$? )
LDFLAGS += $(shell pkg-config --libs $(FFMPEG_LIBS))
CFLAGS += $(shell pkg-config  --cflags $(FFMPEG_LIBS))

EXTRA_DIST = ffmpeg.c

all-local: ffmpeg.so

ffmpeg.so: ffmpeg.c
	@if [ $(EXIST) -eq 0 ]; \
	then \
		$(CC) $< -o $@ $(CFLAGS) $(INCLUDES) $(LDFLAGS) -shared -fPIC; \
	else \
		echo "!!!  these libraries does not exist :: $(GST_LIBS)  !!!"; \
	fi
	
install-exec-local:
	@-if [ $(EXIST) -eq 0 ]; \
	then \
		mkdir -p $(LIB_CODEC_DIR); \
		sudo cp -f ffmpeg.so $(LIB_CODEC_DIR); \
	else \
		echo "!!!  these libraries does not exist :: $(GST_LIBS)  !!!"; \
	fi
	
uninstall-local:
	@-if [ $(EXIST) -eq 0 ]; \
	then \
		sudo rm $(LIB_CODEC_DIR)/ffmpeg.so; \
	else \
		echo "!!!  these libraries does not exist :: $(GST_LIBS)  !!!"; \
	fi

clean-local:
	@-if [ $(EXIST) -eq 0 ]; \
	then \
		rm ffmpeg.so; \
	else \
		echo "!!!  these libraries does not exist :: $(GST_LIBS)  !!!"; \
	fi



